package com.huayi.website.service.impl;

import com.huayi.website.entity.ProductCategoryEntity;
import com.huayi.website.entity.ProductEntity;
import com.huayi.website.repository.ProductRepository;
import com.huayi.website.request.GoodsAddVo;
import com.huayi.website.service.ProductService;
import com.huayi.website.utils.PagingResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductRepository repository;

    @Override
    public List<ProductCategoryEntity> getAllCategoryList() {
        return repository.getAllCategoryList();
    }

    @Override
    public Integer addGoods(GoodsAddVo goodsAddVo, String userName) {
        return repository.addGoods(goodsAddVo,userName);
    }

    @Override
    public Integer addCategory(Integer categoryId,String title, String detail, Integer sort, String image) {
        return repository.addCategory(categoryId,title,detail,sort,image);
    }

    @Override
    public Integer editGoods(Integer productId, GoodsAddVo editVo, String userName) {
        return repository.editGoods(productId, editVo,userName);
    }

    @Override
    public PagingResponse<ProductEntity> getAllList(int pageIndex, int pageSize, String title, Integer categoryId,Integer companyId) {
        return repository.getAllList(pageIndex,pageSize,title,categoryId,companyId);
    }

    @Override
    public ProductEntity getDetailById(Integer id) {
        return repository.getDetailById(id);
    }

    @Override
    public ProductCategoryEntity getCategoryById(Integer id) {
        return repository.getCategoryById(id);
    }

    @Override
    public void deleteGoods(Integer id) {
        repository.deleteGoods(id);
    }

    @Override
    public void deleteCategory(Integer id) {
        repository.deleteCategory(id);
    }
}
